package com.xzy.learn.spring.ioc.overview.config;

import com.xzy.learn.spring.annotation.VIP;
import com.xzy.learn.spring.entity.User;
import org.springframework.beans.factory.config.ObjectFactoryCreatingFactoryBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Primary;

/**
 * @author xzy.xiao
 * @date 2022/5/28  9:49
 */
public class DependencyLookupDemoBeanConfig {
    @Bean
    @Primary
    public User user() {
        return new User(1001L, "张三");
    }

    @Bean
    public User user1() {
        return new User(1002L, "李四");
    }

    @Bean
    @VIP
    public User user2() {
        return new User(1003L, "王五");
    }

    @Bean
    public ObjectFactoryCreatingFactoryBean userObjectFactory() {
        ObjectFactoryCreatingFactoryBean objectFactoryCreatingFactoryBean = new ObjectFactoryCreatingFactoryBean();
        objectFactoryCreatingFactoryBean.setTargetBeanName("user");
        return objectFactoryCreatingFactoryBean;
    }


}
